<?php
/**
 * User: wangjh
 * DateTime: 2018/1/10 10:18
 */

$rabbitServer = ["host" => "127.0.0.1", "port" => 5672, "login" => "guest", "password" => "guest"];
$conn = new AMQPConnection($rabbitServer);
$connRes = $conn->connect();
if (!$connRes) {
	die("Couldn't Connect to Server:" . $rabbitServer['host']);
}
$channel = new AMQPChannel($conn);
$exchange = new AMQPExchange($channel);
$exchange->setName("userRequest");
for ($i = 100; $i < 300; $i++) {
	$arr = ["userid"=>$i, "name"=>"Name". $i];
	$msg = json_encode($arr, JSON_UNESCAPED_UNICODE);
	$exchange->publish($msg, "userRequest");
}
